#!/bin/bash
# Copyright (c) 2000-2016 Synology Inc. All rights reserved.

# $1: config file, $2 milestone
CheckMileStone()
{
	[ $# -ne 2 ] && CheckErrorOut 1 "Wrong number of parameters to $FUNCNAME()."
	[ -f "$1" ] || { echo "Config '$1' not exist!"; return 1; }
	[ -n "$2" ] || { echo "Please specify section name!"; return 1; }
	grep -q "^\[$2\]" $1 && return 0
	echo "Section '$2' not found in '$1'!"
	return 1
}

ResolvePkgVersion() {
	[ $# -ne 1 ] && CheckErrorOut 1 "Wrong number of parameters to $FUNCNAME()."
	local regexp_version='^[0-9][0-9A-Za-z\.\-]*(-[0-9]+)?$'
	[[ "$1" =~ $regexp_version ]] || CheckErrorOut 1 "$1 is not a valid package version!"
	PkgVersion="`echo $1 | awk -F- '{print $NF}'`"
}

[ "$(caller)" != "0 NULL" ] && return 0
`$@`

# vim:ft=sh
